package com.woniu.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class PotentialRabbitmqQueueConfig {
    //创建交换机 队列  以及绑定
    public static String exchangeName = "potentialcustomer_exchange";
    public static String queueName = "potentialcustomer_queue";
    //创建交换机
    @Bean(name = "potentialcustomer_exchange")
    public Exchange createExchage(){
        return ExchangeBuilder.topicExchange(exchangeName)
                .durable(true).build();
    }
    //创建队列
    @Bean(name="potentialcustomer_queue")
    public Queue createQueue(){
        return QueueBuilder.durable(queueName).build();
    }

    @Bean
    public Binding createBinding(@Qualifier("potentialcustomer_queue") Queue queue, @Qualifier("potentialcustomer_exchange") Exchange exchange){
        return BindingBuilder.bind(queue).to(exchange).with("potentialcustomer.#").noargs();
    }

}
